import { AbsDisPtSvc } from "../absdisptsvc";
import common from "../../../common/common";
import {CoordTRFUtil}  from "../../../common/tools/coordtool";

class DisMidPtSvc extends AbsDisPtSvc {
    constructor() {
        super();
        this.desc = "中点"
    }
    subDisplay(aborbPtInfo, map, mapInfo) {
        let size = this.auxMarkSize/mapInfo.getScaling();
        let x0 = aborbPtInfo.pt.x;
        let y0 = aborbPtInfo.pt.y;
        const basePt = {x:0,y:0};
        let baseVct = new common.LGXVector();
        baseVct.setValue(0,1,0);

        let x = basePt.x + size*baseVct.m + x0;
        let y = basePt.y + size*baseVct.n + y0;
        let p1 = {x,y};
        let sp1 = CoordTRFUtil.world2Screen(p1,mapInfo);
        map.lineWidth = 1;
        map.strokeStyle = aborbPtInfo.color.toHexString();
        map.beginPath();
        map.moveTo(sp1.x,sp1.y);

        let vct2 = baseVct.rotateCopy(120);
        x = basePt.x + size*vct2.m + x0;
        y = basePt.y + size*vct2.n + y0;
        let p2 = {x,y};
        let sp2 = CoordTRFUtil.world2Screen(p2,mapInfo);
        map.lineTo(sp2.x,sp2.y);

        let vct3 = baseVct.rotateCopy(240);
        x = basePt.x + size*vct3.m + x0;
        y = basePt.y + size*vct3.n + y0;
        let p3 = {x,y};
        let sp3 = CoordTRFUtil.world2Screen(p3,mapInfo);
        map.lineTo(sp3.x,sp3.y);
        map.closePath();
        map.stroke();
    }
}

export { DisMidPtSvc }